<template>
  <div class="login">
    <div class="login-container">
      <h1>登录</h1>
      <input type="text" v-model="user.name" placeholder="姓名" />
      <input type="text" v-model="user.age" placeholder="年龄" />
      <input type="text" v-model="user.gender" placeholder="性别" />
      <input type="text" v-model="user.school" placeholder="学校" />
      <br />
      <button @click="login">登录</button>
    </div>
  </div>
</template>
<script>
import { mapMutations } from "vuex";
export default {
  name: "login",
  data() {
    return {
      user: {
        name: "",
        age: "",
        gender: "",
        school: ""
      }
    };
  },
  methods: {
    ...mapMutations(["updateUserInfo"]),
    login() {
      this.updateUserInfo(this.user);
      console.log(">>>>", this.$store);
      // this.$router.push('./message')//两种方式
      this.$router.push({
        name: "message"
      });
    }
  }
};
</script>
<style lang="scss">
.login-container {
  width: 700px;
  height: 600px;
  margin: auto;
  border-radius: 20px;
  box-shadow: 0px 0px 2px 1px rgb(0 0 0 / 20%);
  text-align: center;
  h1 {
    padding-top: 40px;
    text-align: center;
  }
  input {
    width: 60%;
    height: 30px;
    margin: 30px 0 0;
    border-radius: 10px;
  }
  button {
    width: 30%;
    margin-top: 40px;
    border-radius: 10px;
    color: #fff;
    font-size: 25px;
    background-color: pink;
  }
}
</style>